<%@ page isELIgnored="false" language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/functions.tld" prefix="fun" %>
<c:set var="_path" value="${pageContext.request.contextPath}"></c:set>
<div id="currMadTable"></div>
<style>
.view_mad_table{
}
.view_mad_table td{
	background: #DFE8F6;
}
pre { 
	whitewhite-space: pre-wrap; /* css-3 */ 
	whitewhite-space: -moz-pre-wrap; /* Mozilla, since 1999 */ 
	whitewhite-space: -pre-wrap; /* Opera 4-6 */ 
	whitewhite-space: -o-pre-wrap; /* Opera 7 */ 
	word-wrap: break-word; /* Internet Explorer 5.5+ */ 
}
</style>
<script>
jQuery(function($){
	$('#currMadTable').datagrid({
		//title:'系统通知列表',//标题
		method:'post',
		iconCls:'icon-edit',//图标
		height:330,
		fitColumns: true,//自动调整各列，用了这个属性，下面各列的宽度值就只是一个比例。
		striped: true,//奇偶行颜色不同
		collapsible:false,//可折叠
		url:"mad/queryMad?startdate=<fmt:formatDate value="${currDate }" pattern="yyyy-MM-dd"/>&enddate=<fmt:formatDate value="${currDate }" pattern="yyyy-MM-dd"/>", //数据来源
		sortName: 'id', //排序的列
		sortOrder: 'desc', //倒序
		remoteSort: true, //服务器端排序
		idField:'id', //主键字段
		queryParams:{}, //查询条件
		pagination:true, //显示分页
		rownumbers:true, //显示行号
		onDblClickRow:function(rowIndex,rowData){
			viewMad(rowData);
		},
		columns:[[
			{field:'title',title:'标题',width:35,sortable:true},
			{field:'value',title:'内容',width:50,sortable:true,formatter:function(v,r){if(v == null || v == undefined){return '';}else{if(v.length > 22){return v.substring(0,20)+ "...";}else{return v;}}}},
			{field:'creatuserid',title:'创建人',width:15,sortable:true}
		]],
		onRowContextMenu : function(e,rowIndex,rowData){
			e.preventDefault();
			var div = $('<div ></div>').appendTo($('body'));
			$(div).append('<div iconCls="icon-add" style="width:150px;">查看</div>');
			$(div).menu({
				onClick : function(){
					viewMad(rowData);
				}
			});
			$(div).menu('show', {
				left:e.pageX,
				top:e.pageY
			});
		}
	});
});
//表格查询
function viewMad(mad){
	$('<div id="_t_mad_div" modal="true"></div>').appendTo($('body'));
	var innerHtml = 
		'<table width="100%" cellspacing="1" cellpadding="0" class="view_mad_table" bgColor="#a6bcd4" >' + 
		'<tr  height="26px">' +
			'<td width="30%">标题</td>' + 
			'<td width="70%">' + mad.title + '</td>' +
		'</tr>' +
		'<tr  height="26px">' +
			'<td>创建人</td>' + 
			'<td>' + mad.creatuserid + '</td>' +
		'</tr>' +
		'<tr valign="top">' +
			'<td valign="top">内容</td>' + 
			'<td valign="top" style="width:270px"><pre>' + mad.value + '</pre></td>' +
		'</tr>' +
	'</table>';
	$('#_t_mad_div').dialog({
		title : '公告:' + mad.title,
		content:innerHtml,
		width:400,
		height:400,
		buttons:[{
			text:'关闭',
			iconCls:'icon-cancel',
			handler:function(){
				$('#_t_mad_div').window('close');
			}
		}],
		onClose:function(){
			$('#_t_mad_div').window('destroy');
		}
	});
}
</script>